<?php 
$tmp=array(); 
while(count($tmp)<5){ 
    $tmp[]=mt_rand(1,20); 
    $tmp=array_unique($tmp); 
} 
print_r($tmp);
?>